<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Services\ConfigService;
use Illuminate\Support\Facades\Storage;

class ConfigController extends Controller
{
    //获取配置信息
    public function index()
    {
        $config = [];
        foreach (ConfigService::all() as $item) {
            if ($item->name === 'material_inadequate') {
                continue;
            }
            if (in_array($item->name, ['logo', 'banner'])) {
                $config[$item->name] = Storage::disk('public')->url($item['content']);
            } else {
                $config[$item->name] = $item['content'];
            }
        }
        return successReturn($config);
    }
}
